package com.leetcode.LC;

public class LC14 {
    public String longestCommonPrefix(String[] strs) {
        if (strs.length==0){
            return "";
        }
        int min=strs[0].length();
        for (String str : strs) {
            if(str.length()<min){
                min=str.length();
            }
        }
        String com = "";
        for (int i = 0; i <= min; i++) {
            com = strs[0].substring(0, i);
            for (String str : strs) {
                if (!str.substring(0, i).equals(com)) {
                    return strs[0].substring(0, i - 1);
                }
            }
        }
        return com;
    }

    public static void main(String[] args) {
        System.out.println(new LC14().longestCommonPrefix(new String[]{"ccc","c","ccc"}));

        System.out.println("dog".contains("dog"));
    }
}
